package com.ken.practice.model.cors;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * <ul>
 * <li>Title: CorsConfig</li>
 * <li>Description: TODO </li>
 * </ul>
 *
 * @author swc
 * @date 2021-08-24 14:12
 */
@Configuration
public class CorsConfig extends WebMvcConfigurerAdapter {

    static final String ORIGINS[] = new String[] { "GET", "POST", "PUT", "DELETE" };

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**").allowedOrigins("*").allowCredentials(false).allowedMethods(ORIGINS).maxAge(3600);
    }
}

